App.directive('select2', function() {
  'use strict';
  
  return {
    restrict: 'A',
    controller: ["$scope", "$element", function($scope, $element){
      
    	$element.addClass('select2');
    	
    	if($element.attr('multiple')) {
    		
    		$element.select2({
    			closeOnSelect: false
    		});
    	}
    	else {
    		
    		$element.select2();
    	}
    }]
  };
});